This is the complete scene code for the scene titled “Toll Booth.” Following it is a breakdown of the code into sections, with eplanations of each section.
****************End of code**************************
In this scene, there is a passageway guarded by a toll booth. An electronic barrier blocks the passage unless the toll is paid. Nearby, there is a pile of trash, including an old computer. The player can open the computer and remove a RAMchip from it.
There is also a stairway leading down to the Creature Room. The statement below moves the player to that scene when the player enters “down:”
IF{TEXT$=DOWN}THEN
MOVE{PLAYER@}TO{CREATURE ROOM}
EXIT
If the player enters “search” the statement below prints a reply, alerting the player to the pile of trash in the corner:
IF{TEXT$=SEARCH}THEN
PRINT{..................................}
PRINT{There is a pile of trash in the corner.}
EXIT
If the player tries to talk to the attendant in the toll booth, the statement below prints the attendant’s reply, which in this case is always the same:
IF{TEXT$=TALK}OR{TEXT$=ASK}OR{TEXT$=INFO}THEN
PRINT{..................................}
PRINT{ATTENDANT: "The toll to leave this world is $10. Would you like to pay the toll now?"}
EXIT
If the player offers anything to the attendant in the toll booth, the code below handles it. The only thing the attendant will accept is cash, to pay the toll:
IF{TEXT$=GIVE}OR{TEXT$=OFFER}THEN
PRINT{..................................}
IF{TEXT$=MONEY}OR{TEXT$=CASH}THEN
IF{CASH>PLAYER@}OR{X1#<10}THEN
PRINT{ATTENDANT: "I'm sorry, but you don't have enough cash to pay the toll."}
EXIT
MOVE{CASH}TO{STORAGE@}
MOVE{BARRIER.1}TO{STORAGE@}
PRINT{ATTENDANT: "Thank you. You may leave at any time."}
PRINT{The electrical barrier is off, allowing passage through the doorway SOUTH.}
EXIT
PRINT{ATTENDANT: "I'm sorry, I can't take anything but cash."}
EXIT
>>>The first statement (above) detects entry of the words “give” or “offer.” If either of these has been entered, then a nested statement checks to see if the words “money” or “cash” have been entered. If this is true, then another nested statement checks to see if the player has any cash. If the player doesn’t have the “cash” object, OR if the variable X1# is less than 10, text is printed telling the player that he doesn’t have enough cash. X1# is used to keep track of how much money the player has. The cost of the toll is $10, so if the variable is less than 10, the player won’t be able to pay the toll.
If the player has the “cash” object, AND X1# is 10 or more, then the innermost statement is ignored, and the exchance is executed. The cash object is moved to storage, and the electrical barrier object (BARRIER.1) is moved to storage. Text is then printed telling the player that he may pass through at any time.
If the player offers anything besides money, then the nested statements are skipped, and text is printed telling the player that the attendant cannot accept anything but cash.<<<
The player can also pay the tol by entering “pay” or by answering “yes” to the attendant’s question (“Would you like to pay the toll?”) The code below takes care of this:
IF{TEXT$=PAY}OR{TEXT$=YES}THEN
PRINT{..................................}
IF{CASH>PLAYER@}OR{X1#<10}THEN
PRINT{ATTENDANT: "I'm sorry, but you don't have enough cash to pay the toll."}
EXIT
MOVE{CASH}TO{STORAGE@}
MOVE{BARRIER.1}TO{STORAGE@}
PRINT{ATTENDANT: "Thank you. You may leave at any time."}
PRINT{The electrical barrier is off, allowing passage through the doorway SOUTH.}
EXIT
>>>In the code above, the first statement detects the words “pay” and “yes.” If either of these words has been entered, then a nested statement checks to see if the player has the cash, AND that the cash variable equals ten. If the player does not have the cash, or the variable is less than 10, then the statement is executed and the player is told that he doesn’t have enough money for the toll.
If the player does have the cash, and X1# equals 10, then the cash is moved to storage, the barrier object (BARRIER.1) is moved to storage, and text is printed telling the player he may pass.<<<
If the player enters the word “no” in answer to the attendant’s question, the statement below prints a reply:
IF{TEXT$==NO}THEN
PRINT{..................................}
PRINT{ATTENDANT: "Ok, when you want to leave just pay the toll."}
EXIT
The section below handles any attempt the player makes to attack or damage the barrier, the toll booth, the computer, or the attendant:
PRINT{The toll booth is protected by unbreakable glass.}
EXIT
IF{TEXT$=COMPUTER}OR{TEXT$=CASE}THEN
PRINT{That might damage whatever is inside.}
EXIT
PRINT{ATTENDANT: "Don't waste your time, stupid! This booth is impervious to any weapons! So there."}
EXIT
>>>In the section above, the first statement detects entry of any “attack” words, such as “shoot” “fire” “swing” or “throw” as well as damage words like “hit” or “break.” If any of these words have been entered, then the first nested statement checks to see if the player has specified an attack on the barrier, such as “shoot barrier.” If so, then text is printed telling the player that the barrier is impervious to his attack. If not, the statement is skipped.
The next nested statement checks to see if the player has specified an attack on the toll booth, or the glass of the booth. If so, then text is printed telling the player that the toll booth is bulletproof and can’t be damaged. If not, then this statement is also skipped.
The third nested statement checks for entry of the words “computer” or “case.” For example, “break computer.” If so, then text is printed telling the player that breaking the computer might damage the contents. If not, then this statement is ignored.
If all the nested statements are false, they are ignored, and text is printed telling the player not to waste his time attacking the attendant.<<<
If the player enters the word “open,” it is handled by the section of code below. The player might try to open the barrier or the toll booth, so statements are included to handle these possibilities. But the only thing in the scene that the player is allowed to open is the computer, where the player will find a RAMchip waiting to be removed:
IF{TEXT$=OPEN}THEN
PRINT{..................................}
IF{TEXT$=BARRIER}THEN
PRINT{The barrier can only be opened by the attendant, when you pay the toll.}
EXIT
IF{TEXT$=GLASS}OR{TEXT$=BOOTH}THEN
PRINT{You can't open the toll booth.}
EXIT
IF{TEXT$=COMPUTER}OR{TEXT$=CASE}THEN
IF{COMPUTER.1=SCENE@}THEN
SOUND{PISTOL-COCKING.1}
MOVE{COMPUTER.1}TO{STORAGE@}
PRINT{The top of the computer comes off easily, revealing the internal components. There is a RAMchip inside.}
EXIT
PRINT{The computer is already open.}
IF{M1#<1}THEN
PRINT{There is a RAMchip in the computer.}
EXIT
EXIT
END
>>>The first statement in the code above tests for entry of the word “open.” If the player has entered “open,” then a nested statement looks for the word “barrier.” If the player has entered both “open” and “barrier,” then text is printed telling the player that the barrier can only be opened by paying the toll. If not, the statement is skipped.
The second nested statement tests for the words “glass” or “booth.” If either of these words is used with “open,” then text is printed telling the player that the tollbooth can’t be opened. If not, then the statement is skipped.
The third statement checks for the words “computer” or “case.” If either of these words has been entered along with “open,” then another statement tests to see if snf object called COMPUTER.1 is in the scene, meaning the computer is closed. If the computer is closed, COMPUTER.1 is moved to storage and text is printed telling the player that a RAMchip is inside.
If the computer is already opened, the previous statement is ignored, and text is printed telling the player that the compuer is already open. Then another statement checks to see if variable M1# is less than 1. If so, this means the RAMchip has not been removed, and text is printed that tells the player there is a RAMchip in the computer.
If the word “open” has been entered, and none of the nested statements is true, then they are ignored, and the “open” statement closes with END, allowing the program to reach the default “open” statement in the Global code.<<<
The code below handles the verbs “get” “take” and “move.” A variable (M1#) is used to keep track of the RAMchip. If M1# is less than 1, then the chip has not been removed from the computer. If M1# equals one, it means the chip has already been taken:
PRINT{There are no more RAMchips in the computer.}
EXIT
PRINT{The computer case is closed. You have to open it before you can take out the RAMchip.}
EXIT
IF{TEXT$=COMPUTER}THEN
PRINT{The computer is too heavy to lug around.}
EXIT
IF{TEXT$=COMPONENT}THEN
PRINT{Except for the RAMchip, the rest of the computer's components are useless.}
EXIT
END
>>>In the code above, the first statement tests for entry of the words “get” “take” or “move.” If any of these words has been entered, a series of nested statements checks for other words specifying what the player wants to take. The first nested statement tests for the words “RAM” or “chip.” If this statement is true, then another statement tests to see if the object COMPUTER.1 is not in the scene, meaning the computer is open. Then the innermost statement checks the value of M1#. If M1# is less than one, a sound is played, the RAMchip is moved to the player, M1# is set to 1, and text is printed telling the player that he now has the RAMchip.
If variable M1# equals one, then the innermost statement is ignored, and text is printed telling the player that there are no more RAMchips in the computer.
If COMPUTER.1 is in the scene, both inner statements are ignored, and text is printed telling the player that the computer is not open.
If the player has not entered “ram” or “chip,” that statement is ignored, and the program continues to the next nested statement, which checks for the word “computer.” If the player tries to take the computer, this statement prints text telling the player that the computer is too heavy to take.
Another statement checks for use of the word “component,” in case the player enters something like “get component,” referring to the internal components of the computer. If this happens, the statement prints text telling the player that only the RAMchip can be removed.
Then the original “get/take” statement closes with END, allowing the program to handle any other use of these verbs in the normal manner.<<<
The next section handles the word “south.” If the barrier object (BARRIER.1) is in
the scene, then a couple of sounds are played, and text is printed telling the player that he has received a shock from the electrical barrier. If BARRIER.1 is not in the scene, then the player is moved to the next scene, titled “The Grand Finale:”
IF{TEXT$=SOUTH}THEN
IF{BARRIER.1=SCENE@}THEN
PRINT{.....................................}
SOUND{RADIO-SND.1}
SOUND{OUCH}
PRINT{The electrical barrier gives you a nasty shock! You can't pass through without paying the toll.}
EXIT
MOVE{PLAYER@}TO{THE GRAND FINALE}
EXIT
The brief statement below prints a line of periods when any of the immobile objects in the scene are clicked, before their descriptions are printed:
The last statement tests for two conditions. First, if the player has clicked on COMPUTER.2, the object that shows the opened computer. And secondly, that M1# is less than one, meaning the ramchip has not yet been taken. If BOTH of these conditions are true, then text is printed telling the player that there is a RAMchip in the computer: